import Vue from 'vue'
import Vuex from 'vuex'
import {TimeStorage} from '../utils/utils';
Vue.use(Vuex)

const store = new Vuex.Store({
    state: {
        hasLogin: TimeStorage.geted('utoken'),
		isNewUser:false,
		userId:"",
        userName: "",
		usermobile:"",
		userInfo:"",
		token:"",
		cityname:"深圳市",
		latitude:"",
		longitude:"",
		winHeight:"",
		isConnected:true,
		networkType:"",
		isInstall:false,//静默安装的安装包是否已安装
		isOpenAccount:false,
		refresh:false
    },
    mutations: {
        login(state, data) {
			TimeStorage.Set('utoken',data.utoken)
			// TimeStorage.Set("utoken",data.utoken,86400)//登录时间24小时
			state.hasLogin = data.utoken;
			// state.isNewUser = data.isNewUser
			TimeStorage.Set('mobile',data.usermobile)
			state.usermobile = data.usermobile || TimeStorage.geted('mobile')
			
        },
        logout(state) {
			TimeStorage.Remove("utoken")
			TimeStorage.Remove('mobile')
			state.usermobile = "";
			state.hasLogin="";
        },
		locationcity(state,City){//设置城市信息
			state.cityname=City.name;
			state.latitude=City.latitude;
			state.longitude=City.longitude;
		},
		changeInstall(state){
			state.isInstall=true;
		},
		changeisOpenAccount(state,isOpenAccount){
			state.isOpenAccount = isOpenAccount
		},
		changeRefresh(state,refresh){
			state.refresh = refresh;
		}
    }
})
export default store
